balance = int(input("请输入您的支付宝余额："))
products = [("iPhone 12 Mini", 699),
            ("iPhone 12", 799),
            ("iPhone 12 Pro", 999),
            ("iPhone 12 Pro Max", 1099)]
cart = []

while True:
    for product in products:
        print(products.index(product) + 1, product[0], product[1])
    selection = int(input("输入商品编号进行购买："))
    if 1 <= selection < len(products) + 1:
        if balance >= products[selection - 1][1]:
            cart.append(products[selection - 1][0])
            balance -= products[selection - 1][1]
            print("购买成功，支付宝余额剩余{}。".format(balance))
            continueShopping = input("是否继续购物：")
            if continueShopping == "否":
                print("您共购买了：{}。支付宝余额剩余{}。".format('，'.join(cart), balance))
                break
        else:
            print("余额不足。")
            continueShopping = input("是否继续购物：")
            if continueShopping == "否":
                print("您已购买了：{}。支付宝余额剩余{}。".format('，'.join(cart), balance))
                break
    else:
        print("无此商品，请重新选择。", "\n")
